from tortoise import fields
from .base import BaseModel, TimestampMixin



class MiniSettings(BaseModel, TimestampMixin):
    name = fields.CharField(max_length=20,  description="配置名称", index=True)
    set_value = fields.CharField(max_length=20,null=True, description="配置值")
    is_active = fields.BooleanField(default=True, description="是否激活")

    class Meta:
        table = "mini_settings"

class MiniAlert(BaseModel, TimestampMixin):
    order = fields.IntField(default=0, description="排序")
    name = fields.CharField(max_length=20,  description="弹屏名称", index=True)
    cover = fields.CharField(max_length=255, null=True, description="封面")
    start_time = fields.DatetimeField(max_length=255,null=True, description="开始时间")
    end_time = fields.DatetimeField(max_length=255,null=True, description="结束时间")
    go_type = fields.IntField(default=0,null=True, description="跳转类型")
    go_url = fields.CharField(max_length=255,null=True, description="跳转值")
    is_active = fields.BooleanField(default=True, description="是否激活")

    class Meta:
        table = "mini_alert"

class MiniTopic(BaseModel, TimestampMixin):
    order = fields.IntField(default=0, description="排序")
    name = fields.CharField(max_length=20,  description="专题名称", index=True)
    content = fields.JSONField(null=True, description="专题配置")
    is_active = fields.BooleanField(default=True, description="是否激活")

    class Meta:
        table = "mini_topic"

class MiniFav(BaseModel, TimestampMixin):
    user_id = fields.IntField(default=0, description="用户id")
    type = fields.IntField(default=0,null=True, description="1商品2圈层")
    type_id = fields.IntField(default=0, description="类型值")

    class Meta:
        table = "mini_fav"


class MiniAuditLog(BaseModel, TimestampMixin):
    user_id = fields.IntField(description="用户ID", index=True)
    username = fields.CharField(max_length=64, default="", description="用户名称", index=True)
    module = fields.CharField(max_length=64, default="", description="功能模块", index=True)
    summary = fields.CharField(max_length=128, default="", description="请求描述", index=True)
    method = fields.CharField(max_length=10, default="", description="请求方法", index=True)
    path = fields.CharField(max_length=255, default="", description="请求路径", index=True)
    status = fields.IntField(default=-1, description="状态码", index=True)
    response_time = fields.IntField(default=0, description="响应时间(单位ms)", index=True)
    datas = fields.JSONField(null=True, description="提交数据")
    class Meta:
        table = "mini_auditlog"

class MiniLayers(BaseModel, TimestampMixin):
    user_id = fields.IntField(description="用户ID", index=True)
    title = fields.CharField(max_length=255, default="",null=True, description="标题")
    content = fields.CharField(max_length=255, default="",null=True, description="内容")
    images = fields.JSONField(null=True, description="多图")
    praise_count = fields.IntField(default=0, description="点赞数")
    review_count = fields.IntField(default=0, description="评论数")
    collect_count = fields.IntField(default=0, description="收藏数")
    comment_at= fields.DatetimeField(null=True,max_length=255, description="最新评论时间")
    status = fields.IntField(default=0, description="0待确认1通过2不通过")
    class Meta:
        table = "mini_layers"

class MiniLike(BaseModel, TimestampMixin):
    user_id = fields.IntField(default=0, description="用户id")
    type = fields.IntField(default=0,null=True, description="1商品2圈层")
    type_id = fields.IntField(default=0, description="类型值")
    class Meta:
        table = "mini_like"

class MiniComment(BaseModel, TimestampMixin):
    user_id = fields.IntField(default=0, description="用户id")
    type = fields.IntField(default=0, null=True, description="1商品2圈层")
    type_id = fields.IntField(default=0, description="类型值")
    content = fields.CharField(max_length=255, default="", null=True, description="评论内容")
    comment_id = fields.IntField(default=0, description="被引用的id")
    praise_count = fields.IntField(default=0, description="点赞数")
    status = fields.IntField(default=0, description="0待确认1通过2不通过")
    class Meta:
        table = "mini_comment"


